package org.glxy.shop.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

@Document(collection = "inventory_logs")
public class InventoryLog {
    @Id
    private String id;
    @Indexed
    private String productId; // 关联的商品ID
    private int operationType; // 操作类型：+1(入库), -1(出库)
    private Long quantity; // 操作数量
    private String remark; // 备注信息
    @Indexed
    private LocalDateTime operationTime; // 操作时间

    // Constructors
    public InventoryLog() {}

    public InventoryLog(String productId, int operationType, Long quantity, String remark) {
        this.productId = productId;
        this.operationType = operationType;
        this.quantity = quantity;
        this.remark = remark;
        this.operationTime = LocalDateTime.now();
    }

    // Getters and setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public int getOperationType() {
        return operationType;
    }

    public void setOperationType(int operationType) {
        this.operationType = operationType;
    }

    public Long getQuantity() {
        return quantity;
    }

    public void setQuantity(Long quantity) {
        this.quantity = quantity;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public LocalDateTime getOperationTime() {
        return operationTime;
    }

    public void setOperationTime(LocalDateTime operationTime) {
        this.operationTime = operationTime;
    }
}